package com.qys.livesMall.shop.modal.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author gmx
 * @since 2023-07-03
 */
@Data
@TableName("h2_seckill_goods")
@Schema(name = "SeckillGoods", description = "")
public class SeckillGoods implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;
    @Schema(description = "商品 ID")
    private String infoId;
    @Schema(description = "sku ID")
    private String skuId;

    @Schema(description = "商品名字")
    private String name;
    @Schema(description = "规格名字")
    private String skuName;

    @Schema(description = "商品图片")
    private String images;

    @Schema(description = "原价格")
        private BigDecimal price;

    @Schema(description = "秒杀价格")
    private BigDecimal seckillPrice;

    @Schema(description = "秒杀商品数")
    private String num;

    @Schema(description = "剩余库存数")
    private Integer storeCount;

    @Schema(description = "描述")
    private String content;

    @Schema(description = "活动ID")
    private String activityId;
    @Schema(description = "排序")
    private Integer sort;
    @Schema(description = "店铺id")
    private String shopId;

    @TableField(exist = false)
    @Schema(description = "存在库存的店铺id")
    private List<Long> shopIds;

    public List<String> getArr() {
        ObjectMapper objectMapper = new ObjectMapper();

        try {
            // 将JSON字符串转换为Java对象
            List<String> shopIds = objectMapper.readValue(this.shopId, new TypeReference<List<String>>(){});
            return shopIds;
            // 现在你可以使用shopIds变量，它是一个List<String>类型的对象
            // 进行你需要的操作
            // ...
        } catch (JsonProcessingException e) {
            // 处理JSON转换异常
            e.printStackTrace();
        }
        return null;
    }
}
